<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%docu_comment}}".
 *
 * @property int $id
 * @property int $docu_id
 * @property string $body
 * @property int $created_at
 * @property int $created_by
 * @property int $status
 *
 * @property Docu $docu
 * @property User $createdBy
 * @property DocuCommentReply[] $docuCommentReplies
 */
class DocuComment extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%docu_comment}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['docu_id', 'body', 'created_at', 'created_by'], 'required'],
            [['docu_id', 'created_at', 'created_by', 'status'], 'integer'],
            [['body'], 'string'],
            [['docu_id'], 'exist', 'skipOnError' => true, 'targetClass' => Docu::className(), 'targetAttribute' => ['docu_id' => 'id']],
            [['created_by'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['created_by' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'docu_id' => Yii::t('app', 'Docu ID'),
            'body' => Yii::t('app', 'Body'),
            'created_at' => Yii::t('app', 'Created At'),
            'created_by' => Yii::t('app', 'Created By'),
            'status' => Yii::t('app', 'Status'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDocu()
    {
        return $this->hasOne(Docu::className(), ['id' => 'docu_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCreatedBy()
    {
        return $this->hasOne(User::className(), ['id' => 'created_by']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDocuCommentReplies()
    {
        return $this->hasMany(DocuCommentReply::className(), ['docu_comment_id' => 'id']);
    }
}
